// TypeScript file
class GoodsUI extends eui.Component
{
    constructor()
    {
        super();
        this.addEventListener( eui.UIEvent.COMPLETE, this.uiCompHandler, this);
        this.skinName = goodsUISkin;
    }

    protected createChildren() : void
    {
        super.createChildren();
    }

    private uiCompHandler(event : eui.UIEvent) : void
    {
        console.log( "\t\tGoodsUI uiCompHandler" );

        //返回按钮
        this.btnReturn.addEventListener( egret.TouchEvent.TOUCH_TAP, ()=>
        {
            this.dispatchEventWith( GameEvents.EVT_RETURN );
        }, this)

        this.fillData();
        //填充数据
    }

    private fillData() : void 
    {
        var dsListGoods : Array<Object> = 
        [
            { icon : "goods01_png", goodsName : "魔法石", comment : "法力加成 +3" },
            { icon : "goods02_png", goodsName : "诅咒娃娃", comment : "咒术加成 +3" },
            { icon : "goods03_png", goodsName : "万圣戒子", comment : "敏捷加成 +3" },
            { icon : "goods04_png", goodsName : "斗篷", comment : "耐力加成 +3" },
            { icon : "goods05_png", goodsName : "鹅毛笔", comment : "精神加成 +3" },
            { icon : "goods06_png", goodsName : "血滴子", comment : "嗜血加成 +3" },
            { icon : "goods07_png", goodsName : "屠龙刀", comment : "力量加成 +3" }
        ];

        this.listGoods.dataProvider = new eui.ArrayCollection( dsListGoods );
        this.listGoods.itemRenderer = GoodsListIRSkin;
    }

    private btnReturn : eui.Button;
    private scrListGoods : eui.Scroller;
    private listGoods : eui.List;
}

class GoodsListIRSkin extends eui.ItemRenderer
{
    constructor()
    {
        super();
        this.skinName = goodsListIRSkin;
    }

    protected createChildren() : void
    {
        super.createChildren();
    }

    protected dataChanged() : void
    {
        console.log( "\t\tGoodsListIRSkin dataChanged " );
    }
}